
#ifndef __BASEMAP_H__
#define __BASEMAP_H__
#include <iostream>
#include <stdio.h>
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
//#include <conio.h>
#endif
#include <string>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <assert.h>
#include <vector>
#include <EchoParser.h>
#include <math.h>
#include <points.h>
#include <pngwriter.h>
//PNG++ START
//#ifn
//#include <cstdlib>
//#include <iostream>
#ifndef _STARTPNG_
#define _STARTPNG_
#include <ostream>
#include <png.hpp>
//PNG++ END
#endif

#define BOX_TO_PIXEL 1
#define STARTING_X 0
#define STARTING_Y 0
#define STARTING_ANGLE 45
#define STARTING_X_OFFSET 10 //should always be greater than MASK_SIZE
#define STARTING_Y_OFFSET 10 //should always be greater than MASK_SIZE
#define DISTANCE_MULTIPLIER 10
#define ANGLE_BOUND 20
#define SCREEN_HEIGHT 600
#define SCREEN_WIDTH 600
#define RESOLUTION 3 //this defines how finely the float values of the point coordinates match to the grid index
#define MASK_SIZE 7 //the smoothing mask size n X n
#define TIME_OFFSET 10//the TIME_OFFSET for audio texturing in secons from current tatum
#define TIME_RANGE 10//the range of time to check for audio texturing in. So for time t check in time [t+TIME_OFFSET, t+TIME_OFFSET+TIMERANGE]
#define AUDIO_TEXTURE_THRESHOLD 3//threshold for euclidean  distance
#define MATRIX_SIZE 5//(it is in seconds) size of the matrix whose euclidean distance from other such maticies is caluculate. Its size is 12 X (MATRIX_SIZE * number of tatums per second)
//pitch:								sun.xml									track4.xml
	//.5,5 gives atpoint for pitch			3										0
	//1,5 gives atpoint for pitch			4										0
	//2,5 gives atpoint for pitch			4										3
//timbre:
	//200,5 gives 3 atpoints for timbre
	//400,5 gives 5 atpoint for timbre
	//800,5 gives 5 atpoint for timbre


typedef struct aTatum
{
	int segNumber;
	int audioTextureTatumNumber; //the tatum number to which this tatum can jump from.
	float time;
	float pitch[12];
	float timbre[12];
}Tatum;


class BaseMap
{
private:
EchoParser *parsedSong;
vector<Segment*>* segments;
vector<Point*>* points;
vector<Point*>* ATpoints;
int **abasemap;
float maxX, maxY;
int gridsize;
int numberOfSegments;
float *pitch[12];
float *timbre[12];
void write(int** map, int h, int w);

public:
	BaseMap(EchoParser *aparsedSong);
	void findPoints();
	void audioTexture();
	void createBaseMap(int mode); //1 = only point, 2 = only ATpoints, 3 = both
	void smoothBaseMap();
	void printMap();
	int** getBaseMap();
	int getGridSize();
	vector<Point*>* getPoints();
	vector<Point*>* getATPoints();
	void writeheightmap();//write the heightmap.png file
};

#endif

